<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>滴答办公系统-学科列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
<script src="media/js/jquery.min.js"></script>
<style type="text/css">
  td > .layui-table-cell{
      height:48px;
      line-height: 48px;
  }
</style>
</head>
<body>
	<div class="layui-container">
    
    <table class="layui-table" id="layui_table_id" lay-filter="dataTable1"></table>
    
	</div>
	<script src="media/layui/layui.js"></script>
  
  <script type="text/html" id="operate">
    <a class="layui-btn layui-btn-mini" href="courseupdate.html?id={{d.id}}">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" onclick="deleteMajor({{d.id}});">删除</a>
  </script>
	
	<script type="text/javascript">
    layui.use('table', function() {
      var table = layui.table;
    
      //第一个实例
      table.render({
        id: "dataTable1",
        elem: '#layui_table_id',
        height: 510,
        url: '/emp/major/getMajorsList', //数据接口
        page: true,
        limit: 10,
        contentType: "application/x-www-form-urlencoded",
        method: 'post',
        cols: [
          [ //表头
            {
              field: 'id',
              title: '序号',
              width: 85,
              align: 'center',
              sort: true
            }, {
              field: 'major_name',
              title: '学科名称',
              width: 220,
              align: 'center'
            }, {
              field: 'major_time',
              title: '周数',
              width: 200,
              align: 'center'
            }, {
              field: 'major_date',
              title: '成立日期',
              width: 220,
              align: 'center'
            }, {
              field: 'major_type_name',
              title: '类型',
              width: 200,
              align: 'center'
            }, {
              title: '操作',
              width: 208,
              align: 'center',
              templet: '#operate'
            }
          ]
        ]
      });
    
    });
    
    /*用户-删除*/
    function deleteMajor(id) {
      layer.confirm('确认要删除吗？', function() {
    
        $.ajax({
          method: "POST",
          url: "/emp/major/delMajor",
          data: {
            id: id
          }, //提交表单的数据
          success: function(res) {
           window.location.reload();
          },
          error: function() {
            layer.close(loading);
            layer.msg('操作失败', {
              icon: 2
            });
          }
        });
      });
    }
	</script>
	
	
</body>
</html>